package com.fusion.core.comm.rpc;

import java.io.IOException;

import com.fusion.core.comm.Packet;
import com.fusion.core.comm.RPC;
import com.fusion.core.comm.T;

/**
 * @author SwethaShivakumar 
 * Project: fusion
 * Date: Mar 9, 2009
 * URL: http://fusionwiki.co.cc
 * Mail Me At: shiva@fusionproject.co.cc
 */
public class AwayStatus extends RPC {
    private boolean away;

    public AwayStatus() {
    }

    public AwayStatus(boolean away) {
        this.away = away;
    }

    public void execute(Packet data) throws IOException {
        away = data.readBoolean();
        if(T.t)T.info("User "+con.getRemoteFriend()+" changes away status: "+away);
        con.getRemoteFriend().setAway(away);
        core.getUICallback().nodeOrSubnodesUpdated(con.getRemoteFriend());
    }

    public Packet serializeTo(Packet p) {
        p.writeBoolean(away);
        return p;
    }
}
